package sigmacinema.ui.tapestry.controller;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry.html.BasePage;
import com.javaforge.tapestry.spring.annotations.InjectSpring;
import org.apache.tapestry.annotations.Bean;
import org.apache.tapestry.valid.ValidationDelegate;

import sigmacinema.entity.Hall;
import sigmacinema.service.SigmaCinemaService;

public abstract class HallController extends BasePage{
	@InjectSpring("SigmaCinemaService")
    public abstract SigmaCinemaService getSigmaCinemaService();
	@Bean
        public abstract ValidationDelegate getDelegate();
	private Hall hall = new Hall();
	private List<Hall> listHall = new ArrayList<Hall>();
	
	public Hall getHall() {
		return hall;
	}


	public void setHall(Hall hall) {
		this.hall = hall;
	}
	
	public List<Hall> getListHall() {
		listHall=getSigmaCinemaService().FindAllHall();
		return listHall;
	}


	public void setListHall(List<Hall> listHall) {
		this.listHall = listHall;
	}


	public String save(){
            ValidationDelegate delegate = getDelegate();    
            if(delegate.getHasErrors()){
                return null;
            }else{
                getSigmaCinemaService().saveHall(hall);
		return "admin/ViewHall";
            }
		
	}
        
        public String onDelete(String id) {
            hall.setId(id);
            getSigmaCinemaService().deleteHall(hall);
            return "admin/ViewHall";
        }

}
